package main

import (
	"fmt"
	"jsjb/connect"
	"jsjb/route"
	"jsjb/setting"
)

func main() {
	//加载配置文件
	setting.Init("./conf/config.ini")
	//链接数据库
	err := connect.InitDb(setting.Conf.MySQLConfig)
	if err != nil {
		fmt.Printf("init mysql failed, err:%v\n", err)
		return
	}
	//程序退出关闭链接
	//defer connect.Close()
	//模型绑定
	//connect.DB.AutoMigrate(&model.Todo{})
	//注册路由
	r := route.SetupRoute()
	if err := r.Run(fmt.Sprintf(":%d", setting.Conf.Port)); err != nil {
		fmt.Printf("server startup failed, err:%v\n", err)
	}
}
